<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width,initial-scale=1.0">
  <title>chapter1-2</title>
</head>
<body>
<div id="app"></div>
<!-- 定义一个canvas标签 -->
<canvas id="canvas" width="300" height="200"></canvas>    
<script>
  const canvas = document.querySelector('canvas') // 获取canvas元素
  let ctx = canvas.getContext('2d') // 获取画布上下文
  ctx.strokeStyle = 'red' // 设置线条样式 - 红色边框
  ctx.lineWidth = 2 // 设置线宽 - 2像素
  ctx.strokeRect(20, 20, 100, 60) // 绘制矩形（长100 x 宽60）
</script>
</body>
</html>